
//弹出登录框
var dlObj =document.querySelector('.member div')
dlObj.onclick = function() {
    document.querySelector('section.login').style.visibility = 'visible'
}

//隐藏对话框
var guanbiObj = document.querySelector('section.login  i.icon-close')
guanbiObj.onclick = function () {
    document.querySelector('section.login').style.visibility = 'hidden'
}


// # 登录对话框-蓝色区域拖拽
var tzBtn =document.querySelector('section.login .menu')
tzBtn.onmousedown = function (evt) {
    var oldE = evt || window.event
    
    document.onmousemove = function (evt) {
        var e = evt || window.event
        var left = e.clientX-oldE.offsetX
        var top = e.clientY-oldE.offsetY
        if (left<0) left = 0
        if (top <0) top = 0
        var dlBtn = document.querySelector('section.login .item')
        var maxLeft = (document.documentElement.clientWidth || window.innerWidth)-dlBtn.offsetWidth
        var maxTOP = (document.documentElement.clientHeight || window.innerHeight) -dlBtn.offsetHeight
        if (left>maxLeft) left = maxLeft
        if(top>maxTOP)  top = maxTOP

        dlBtn.style.position= 'absolute'
        dlBtn.style.left = left + 'px'
        dlBtn.style.top = top +'px'

    }
    document.onmouseup = function () {
        document.onmousemove = null
    }
}
 
// # 登录表单验证
var dlzcBtn = document.querySelector('section.login .submit')
dlzcBtn.onclick = function () {
    var num = 0
   var zhObj= document.querySelector('section.login .mobile')
   if (zhObj.value=='' || zhObj.value.length !=11 || !Number(zhObj.value)){
        document.querySelector('section.login .form > p:nth-of-type(3)').innerText= '请输入手机号'
   } else{
       num++
        document.querySelector('section.login .form > p:nth-of-type(3)').innerText= ''
   }

   var passwordObj = document.querySelector('section.login .password')
   if (passwordObj.value.length !=4){
    document.querySelector('section.login .form > p:nth-of-type(4)').innerText= '请输入4位数验证码'
   }    else{
       num++
    document.querySelector('section.login .form > p:nth-of-type(4)').innerText= ''
   }
   if(num==2){
    alert('数据提交中')
    }
}
// # 登录倒计时（留心：重复点击BUG  disabled属性
var num = 10
var yzmBtn = document.querySelector('section.login .captcha')
yzmBtn.onclick = function (){
    var xwyzmOBJ= document.querySelector('section .captcha')
    var captchaObj = document.querySelector('section.captcha')
    captchaObj.style.visibility = 'visible'
    document.querySelector('section.captcha i.icon-close').onclick= function () {
        captchaObj.style.visibility = 'hidden'
    }
    var dragBtn = captchaObj.querySelector('.drag .btn')
    dragBtn.onmousedown = function() {
        document.onmousemove = function(evt) {
            var e = evt || window.event
            var left = e.clientX - (captchaObj.offsetLeft - captchaObj.offsetWidth/2) - dragBtn.offsetWidth
            dragBtn.style.left = left + 'px'
            captchaObj.querySelector('.check img:nth-of-type(2)').style.left = left + 'px'
        }
        document.onmouseup = function() {
            document.onmousemove = null
            var value = parseInt(dragBtn.style.left)
            if (value >= 260 && value<=265)
            {
                captchaObj.style.visibility = 'hidden'
            yzmBtn.innerText= num+'秒后重发'
            yzmBtn.disabled = true
    t=setInterval(function(){
        if(num<=1){
            clearInterval(t)
            yzmBtn.innerText= '重新发送'
            num = 10
            yzmBtn.disabled = false
            return
        }
        num--
        yzmBtn.innerText= num+'秒后重发'


    },1000)
}

dragBtn.style.left =  '0px'
captchaObj.querySelector('.check img:nth-of-type(2)').style.left =  '0px'


 }
 }
 return
}
        
